<script type="text/javascript">
$(document).ready(function() {

	   //listen for the form beeing submitted
	   $("#myForm").submit(function(){
	      //get the url for the form
	      var url=$("#myForm").attr("action");
	   
	      //start send the post request
	       $.post(url,{
	           formName:$("#nameid").val(),
	           other:"attributes"
	       },function(data){
	           //the response is in the data variable
	   
	            if(data.response==200 ){           
	                $('#output').html(data.greeting);
	                $('#output').css("color","red");
	            }
	           else if(data.response==400){//bad request
	               $('#output').html(data.greeting);
	               $('#output').css("color","red");
	          }
	       
	       },"json");//make sure the the response is in json format

	      //we dont what the browser to submit the form
	      return false;
	   });


	});


<!--

//-->
</script>




<h1>Employee list</h1>
<div id="content">
  <form id="myForm" action="{{path('my_app_greeting', 'formName': 'myForm')}}" method="POST" >
    Write your name here: 
    <input type="text" name="name" id="nameId" value="" /><br />
    <input type="submit" value="Send" />
  </form>
 </div>
 <div id="output"></div>
</div>



<table class="records_list">
    <thead>
        <tr>
            <th>Id</th>
            <th>Nom</th>
            <th>Prenom</th>
            <th>Age</th>
            <th>Salaire</th>
            <th>Actions</th>
        </tr>
    </thead>
    <tbody>
    {% for entity in entities %}
        <tr>
            <td><a href="{{ path('employee_show', { 'id': entity.id }) }}">{{ entity.id }}</a></td>
            <td>{{ entity.nom }}</td>
            <td>{{ entity.prenom }}</td>
            <td>{{ entity.age }}</td>
            <td>{{ entity.salaire }}</td>
            <td>
                <ul>
                    <li>
                        <a href="{{ path('employee_show', { 'id': entity.id }) }}">show</a>
                    </li>
                    <li>
                        <a href="{{ path('employee_edit', { 'id': entity.id }) }}">edit</a>
                    </li>
                </ul>
            </td>
        </tr>
    {% endfor %}
    </tbody>
</table>

<ul>
    <li>
        <a href="{{ path('employee_new') }}">
            Create a new entry
        </a>
    </li>
</ul>
